package com.vinobase.model.bean;


import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Unindexed;
import com.vinobase.controller.management.CountryForm;

import javax.persistence.Id;

@Entity
public class Country {

    @Id
    private Long id;

    @Unindexed
    private boolean global = false;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public boolean isGlobal() {
        return global;
    }

    public void setGlobal(boolean global) {
        this.global = global;
    }

    public CountryForm getFormObject(){
        CountryForm cf = new CountryForm();
        cf.setId(id);
        return cf;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Country country = (Country) o;

        if (global != country.global) return false;
        if (id != null ? !id.equals(country.id) : country.id != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (global ? 1 : 0);
        return result;
    }
}
